package com.example.blog.ws.controller;

import com.example.blog.pojo.Result;
import com.example.blog.pojo.User;
import com.example.blog.ws.service.ChatMassageService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/webSocket")
public class WebSocketController {
    @Resource
    private ChatMassageService chatMassageService;

    @GetMapping("/getGroupMessage")
    public Result getGroupMessage() {
        return chatMassageService.getGroupMessage();
    }

    @GetMapping("/getSingleMessage")
    public Result getSingleMessage(@RequestParam String fromUserId
            , @RequestParam String receiveUserId) {
        return chatMassageService.getSingleMessage(fromUserId, receiveUserId);
    }
    @GetMapping("/getCount")
    public Result<T> getOnlineCount(){
        return chatMassageService.getOnlineCount();
    }

    @GetMapping("/getUserByName")
    public Result<User> getUserByName(@RequestParam String name){
        return chatMassageService.getUserByName(name);
    }
}